package com.cashmama.market.api.infras.utils;

import com.cashmama.market.api.infras.app.RequestBasicInfo;
import com.cashmama.market.api.infras.enums.order.AppRequestTypeEnum;

/**
 * @program: market-api
 * @description
 * @author: frank
 * @create: 2020-03-10 16:44
 **/
public class VersionUtils {

    public static boolean version_more_than_1_0_7(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() > 15) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_more_than_1_1_0(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() > 17) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_less_than_1_1_4(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return true;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return true;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() >= 21) {
                return false;
            }
        }

        return true;
    }

    public static boolean version_more_than_1_1_8(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() >= 20000) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_more_than_1_1_9(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() >= 26) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_less_than_1_0_4(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() < 28) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_less_than_1_0_5(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() <= 29) {
                return true;
            }
        }

        return false;
    }

    public static boolean version_less_than_1_1_9(RequestBasicInfo requestBasicInfo) {

        if (requestBasicInfo == null) {
            return false;
        }

        if (StringUtils.isEmpty(requestBasicInfo.getAppClient())
                || requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.WAP.getDesc())) {
            return false;
        }

        if (StringUtils.isNotEmpty(requestBasicInfo.getAppClient())) {
            if (requestBasicInfo.getAppClient().equals(AppRequestTypeEnum.ANDRIOD.getDesc())
                    && requestBasicInfo.getVersionCode() != null
                    && requestBasicInfo.getVersionCode() < 26) {
                return true;
            }
        }

        return false;
    }
}
